package com.woniu.payback_font.web;

import com.github.pagehelper.PageInfo;
import com.woniu.payback_font.entity.Account;
import com.woniu.payback_font.result.ResponseResult;
import com.woniu.payback_font.service.AccountService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api("账户查询接口api")
@RestController
@RequestMapping("ananger")
public class AccountController {

    @Autowired
    AccountService accountService;


    /**
     * 账户条件查询接口
     * @param pageNum
     * @param pageSize
     * @param aUid
     * @param aName
     * @param aMobile
     * @param aIdcar
     * @return
     */
    @GetMapping("/showAll")
    public ResponseResult<PageInfo<Account>> showLoan(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum ,
                                                      @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize,
                                                      String aUid, String aName, String aMobile, String aIdcar){
        ResponseResult result = null;
        PageInfo<Account> info = accountService.selectAllList(pageNum, pageSize, aUid, aName, aMobile, aIdcar);
        if(info==null){
            result=new ResponseResult(204,"查询失败");
        }else{
            result=new ResponseResult(200,"查询成功");
            result.setData(info);
        }
        return result;
    }

    @GetMapping("/findOne/{aUid}")
    public ResponseResult<Account> findOne(@PathVariable("aUid") String aUid){
        ResponseResult result = null;
        Account info = accountService.findOne(aUid);
        if(info==null){
            result=new ResponseResult(204,"查询失败");
        }else{
            result=new ResponseResult(200,"查询成功");
            result.setData(info);
        }
        return result;
    }
}
